<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class user extends Model
{
    use HasFactory;

    protected $table = 'user';

    /**
     * 获取所有用户
     * @param string $limit
     * @return array
     */
    public static function getAllUser($limit = '')
    {
        $table = self::query();
        if($limit) $table = $table->limit($limit);
        return $table->get()->toArray();
    }

    /**
     * 根据用户id获取用户信息
     * @param $id
     * @return array
     */
    public static function getUserById($id)
    {
        return self::query()->where('id',$id)->first()->toArray();
    }
}
